#pragma warning( disable: 4995 4996 )

#include <windows.h>
#include <strsafe.h>
#include <assert.h>

#include "BasicDataTypes.h"
#include "Collections.h"
#include "DirectoriesAndFiles.h"
#include "Forms.h"

#include "commctrl.h"
#include "Form1.h"
#include "Program.h"


// BUGBUG - need to capture comments here
// GoNative Replacement Hash: DF38F4D1D620113A109BDFA8471F28924FFDAA90
void Test_002::Program::Main()
{
	Application::EnableVisualStyles();
	Application::SetCompatibleTextRenderingDefault(false);
	Application::Run(new Form1());
}




HINSTANCE   g_hInstance = NULL;

Test_002::Form1	Form1;




LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{
		case WM_CREATE:
			Form1.OnCreate( hWnd );
			break;

		case WM_TIMER:
			Form1.OnTimer(wParam,lParam);
			break;

		case WM_COMMAND:
			Form1.OnCommand(wParam,lParam);
			break;

		case WM_ACTIVATE:
			Form1.OnActivate();
			break;

		case WM_SIZE:
			Form1.OnSize();
			break;

		case WM_PAINT:
			Form1.OnPaint();
			break;

		case WM_DESTROY:
			Form1.OnDestroy();
			PostQuitMessage(0);
			break;

		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}


BOOL InitInstance( HINSTANCE hInstance, int nCmdShow )
{
	g_hInstance = hInstance; // Store instance handle in our global variable

	HWND hWnd = CreateWindow( Form1.Text.ToString(), Form1.Text.ToString(), 
	WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL );

	Form1.hWnd = hWnd;
	Form1.hInstance = g_hInstance;

	if (!hWnd)
		return FALSE;

	ShowWindow( hWnd, nCmdShow );
	UpdateWindow( hWnd );
	return TRUE;
}


ATOM MyRegisterClass(HINSTANCE hInstance)
{
	WNDCLASSEX wcex = {0};

	wcex.cbSize = sizeof(WNDCLASSEX);
	wcex.style			= CS_HREDRAW | CS_VREDRAW;
	wcex.lpfnWndProc	= WndProc;
	wcex.hInstance		= hInstance;
	wcex.hCursor		= LoadCursor( NULL, IDC_ARROW );
	wcex.hbrBackground	= (HBRUSH)( COLOR_WINDOW+1 );
	wcex.lpszClassName  = Form1.Name.ToString();

	return RegisterClassEx( &wcex );
}

int APIENTRY WinMain(   HINSTANCE   hInstance,
HINSTANCE   hPrevInstance,
LPSTR       lpCmdLine,
int         nCmdShow )
{
	UNREFERENCED_PARAMETER( hPrevInstance );
	UNREFERENCED_PARAMETER( lpCmdLine );

	MSG msg;
	HACCEL hAccelTable;

	MyRegisterClass( hInstance );

	if ( !InitInstance( hInstance, nCmdShow ) )
		return FALSE;

	INITCOMMONCONTROLSEX ic = {0};
	ic.dwSize = sizeof(ic);
	ic.dwICC = ICC_BAR_CLASSES | ICC_STANDARD_CLASSES;
	InitCommonControlsEx( &ic );

	hAccelTable = Form1.Accelerators(); 

	while( GetMessage( &msg, NULL, 0, 0 ) )
		if( !TranslateAccelerator( msg.hwnd, hAccelTable, &msg ) )
		{
			TranslateMessage( &msg );
			DispatchMessage( &msg );
		}

	return (int) msg.wParam;
}






